<div id="giftpackage_div">
<{capture name="sidebar"}>
<div class="side-bx spage-side">
    <div class="spage-side-nav">
        <ul>
            <li class="l-handle all" ><span>基本设置</span></li>
            <{foreach from=$sections item=section name="sec"}>
                <{if $env.foreach.sec.iteration neq 1}>
                <li class="l-handle" ><span><{$section.label}></span></li>
                <{/if}>
            <{/foreach}>
        </ul>
    </div>
</div>

<{/capture}>


<{foreach from=$sections item=section}>
<div class="spage-main-box">
  <{include file=$section.file app=giftpackage}>
</div>
<{/foreach}>

<{capture name='footbar'}>
<table cellspacing="0" cellpadding="0" class="table-action">
      <tbody><tr valign="middle">
        <td>
        <{assign var="___a"  value="关  闭"}>
        <{assign var="___c"  value=$___b2c='确定退出?'|t:'b2c'}>
            <{button label=$___b2c="保存并关闭窗口"|t:'b2c' class="btn-primary" onclick="submitForm(event,2)"}>
            <!--<{button label="保  存" class="btn-primary" onclick="submitForm(event,1)"}>-->
            <{button label=$___content=$___a|t:'content' class="btn-secondary" onclick="if(confirm('{$___c}'))window.close()"}>
        </td>
        </tr>
        </tbody>
</table>

<script>
var __radio_name;
var submitForm = function (event,sign){
       var _form=$('giftpackage_form');

        switch (sign){
            case 1:
            var target={
                    onComplete:function(){
                        location.reload();
                }};
            break;
            case 2:
            var target={
                    onComplete:function(rs){
                        if(JSON.decode(rs).error) {
                            return ;
                        }
                        if(window.opener.finderGroup&&window.opener.finderGroup['<{$env.get.finder_id}>']){
                            window.opener.finderGroup['<{$env.get.finder_id}>'].refresh();
                        }
                        window.close();
                    }};
            break;
       }
       _form.store('target',target);
       _form.fireEvent('submit',new Event(event));
    };
</script>
<{/capture}>
</div>
<script>
$('giftpackage_div').retrieve('setTabs',function(){
		 var gtabs=$$('#menu-desktop .spage-side-nav li.l-handle');
		 new ItemAgg(gtabs,$$('#giftpackage_div .spage-main-box'),{
			activeName:'cur',
			onActive:function(tab,item){
				 var anotherItems=$$(Array.from(this.items).remove(item));
                  if(tab.hasClass('all')){
                     anotherItems.show();
                  }else{
                     anotherItems.hide();
                  }
        	}
		 });
}());

</script>